#include "MainHeader.h"
cWorkArea::~cWorkArea(){}
cWorkArea::cWorkArea(){ }
int cWorkArea::Init(HWND setup){
    hwndBound=setup;

    cboArea.Init(GetDlgItem(hwndMain,ID_cboArea));
	cboRoom.Init(GetDlgItem(hwndMain,ID_cboRoom));
	lblArea=GetDlgItem(hwndMain,idArea);
	lblRoom=GetDlgItem(hwndMain,idRoom);

    lblClipData=GetDlgItem(hwndMain,ID_lblClip);
    chkForeground.SetCnt(GetDlgItem(hwndMain,ID_chkLevel));
	chkMidLayer.SetCnt(GetDlgItem(hwndMain,ID_chkMid));
	chkBlackLayer.SetCnt(GetDlgItem(hwndMain,ID_chkBack));
	chkClipdata.SetCnt(GetDlgItem(hwndMain,ID_chkMovement));
	cboClipdata.Init(GetDlgItem(hwndMain,ID_cboClip));
return 0;
}
int cWorkArea::Resize(){

    int width=0;
	RECT scroll;
	RECT Bound;
	RECT MapNav;
	RECT rEdit;
	int newmax=0;
	char buff[256]={0};
	RECT cA,cR,lA,lR,cMovement,lMovement;
	RECT rF,rL,rB, rC;
	RECT rID;
	GetWindowRect(GetDlgItem(hwndMain, idMap),&MapNav);
    GetWindowRect(GetDlgItem(hwndMain,ID_cboArea),&cA);
	GetWindowRect(GetDlgItem(hwndMain,ID_cboRoom),&cR);
	GetWindowRect(GetDlgItem(hwndMain,idArea),&lA);
	GetWindowRect(GetDlgItem(hwndMain,idRoom),&lR);
    GetWindowRect(lblClipData,&lMovement);
	GetWindowRect(cboClipdata.thishwnd(),&cMovement);


	lMovement.bottom -=lMovement.top;
	lMovement.right -= lMovement.left;
	cMovement.bottom -=cMovement.top;
	cMovement.right -= cMovement.left;

    //area
	cA.right -= cA.left;
	cA.bottom -= cA.top;

    lA.right -= lA.left;
	lA.bottom -= lA.top;
	//Room
	cR.right -= cR.left;
	cR.bottom -= cR.top;

    lR.right -= lR.left;
	lR.bottom -= lR.top;

	width = ((cA.right + lA.right) > (cR.right + lR.right)? (cA.right + lA.right) : (cR.right + lR.right))+128;
	GetWindowRect(GetDlgItem(hwndMain, idNavigation), &Bound);
	Bound.left = MapNav.right + 6;
	Bound.right = width;
	Bound.bottom -= Bound.top;
    Bound.top = 0;
	MoveWindow(GetDlgItem(hwndMain, idNavigation),Bound.left,Bound.top,Bound.right,Bound.bottom,0);
	
	
	lA.left = Bound.left + 16;
    lA.top = Bound.top + 32;

	cA.left = lA.left+lA.right + 5;
	cA.top = lA.top;

	lR.left = lA.left;
    lR.top = Bound.top + 25+32;

	cR.left = lR.left + lR.right + 4;
	cR.top = lR.top;
    
	lMovement.left = lR.left;
    lMovement.top = lR.top + lR.bottom + 5;

	cMovement.top = lMovement.top;
	cMovement.left = lMovement.left + lMovement.right + 8;

    MoveWindow(lblClipData,lMovement.left, lMovement.top, lMovement.right, lMovement.bottom,0);
	MoveWindow(cboClipdata.thishwnd(),cMovement.left, cMovement.top, cMovement.right, cMovement.bottom,0);

    MoveWindow(lblArea,lA.left, lA.top,lA.right,lA.bottom,0);
    MoveWindow(cboArea.thishwnd(),cA.left, cA.top,cA.right,cA.bottom,0);

    MoveWindow(lblRoom,lR.left, lR.top,lR.right,lR.bottom,0);
    MoveWindow(cboRoom.thishwnd(),cR.left, cR.top,cR.right,cR.bottom,0);  
    //Now we'll do all the shit for the Edit box. 
	
	GetWindowRect(GetDlgItem(hwndMain,ID_EditFrame),&rEdit);
	rEdit.right -= rEdit.left;
	rEdit.bottom -= rEdit.top;
	rEdit.left =  cA.left+cA.right + 8;
	rEdit.top = lA.top-2;
    MoveWindow(GetDlgItem(hwndMain,ID_EditFrame),rEdit.left, rEdit.top, rEdit.right, rEdit.bottom,0);
    

	GetWindowRect(chkForeground.check,&rF);
	GetWindowRect(chkMidLayer.check,&rL);
	GetWindowRect(chkBlackLayer.check,&rB);
	GetWindowRect( chkClipdata.check,&rC);
	
	rF.bottom -= rF.top;
	rF.right -= rF.left;

	rL.bottom -= rL.top;
	rL.right -= rL.left;

	rB.bottom -= rB.top;
	rB.right -= rB.left;

	rC.bottom -= rC.top;
	rC.right -= rC.left;
    rF.left=rL.left = rB.left = rC.left = rEdit.left + 4;
	rF.top = rEdit.top + 14;
	rL.top = rF.top + rF.bottom + 1;
	rB.top = rL.top + rL.bottom + 1;
	rC.top = rB.top + rB.bottom + 1;

	MoveWindow(chkForeground.check,rF.left, rF.top, rF.right, rF.bottom,0);
	MoveWindow(chkMidLayer.check,rL.left, rL.top, rL.right, rL.bottom,0);
	MoveWindow(chkBlackLayer.check,rB.left, rB.top, rB.right, rB.bottom,0);
	MoveWindow(chkClipdata.check,rC.left, rC.top, rC.right, rC.bottom,0);
    //We got one more fucker to do! -_-
	GetWindowRect(GetDlgItem(hwndMain,ID_clipshow),&rID);
	rID.bottom -= rID.top;//Only one we can't dissmiss
	//Everything gets size to it's amount
    GetWindowText(GetDlgItem(hwndMain,ID_clipshow),buff, 256);
    rID.right = strlen(buff)*8;//4 pix?
	rID.left = lMovement.left;
	rID.top = cMovement.top + cMovement.bottom + 48;
	MoveWindow(GetDlgItem(hwndMain,ID_clipshow),rID.left, rID.top, rID.right, rID.bottom,0);
	return 0; 




}